✨ BCA JUL24 Batch ✨

Join Our WhatsApp Group

Anukasif Pic

3.1 - Decision Making Statements - MCQs

Interactive MCQs Quiz

Test your knowledge with these questions

1. What is the purpose of an "if" statement in a program?

2. Which of the following is a correct syntax for an "if" statement?

3. Which of the following is a valid relational operator used in decision statements?

4. What will happen if the condition in an "if" statement evaluates to false?

5. Which logical operator is used to check if both conditions are true?

6. Which of the following is an example of an "if-else" statement?

7. What will the following code output if the user enters 150?

#include
            void main() {
                int no;
                printf("enter a no");
                scanf("%d", &no);
                if(no > 100) {
                    printf("No is >100 ");
                    printf("\n %d", no);
                }
                printf("\n End of program");
            }

8. What is the output of the following code if the user enters 3?

#include
            void main() {
                int no;
                printf("enter a no");
                scanf("%d", &no);
                if(no % 2 == 0) {
                    printf("No is Even ");
                } else {
                    printf("No is Odd ");
                }
                printf("\n End of program");
            }

9. Which statement can be used to check multiple conditions in a decision-making process?

10. In a decision statement, what is the purpose of the else block?

11. Which of the following is a logical operator used in decision statements?

12. What is the significance of parentheses () in an "if" condition?

13. What keyword is used to introduce an alternative condition in decision-making statements?

14. Which relational operator checks if two values are not equal?

15. What kind of decision-making structure allows for multiple "if" statements one after another?

16. What is the purpose of using multiple if conditions?

17. Is there a limit on the number of if conditions in a multiple if structure?

18. How many blocks of statements are executed in a multiple if structure?

19. What happens if the first condition in an if-else if structure is true?

20. In the following code, what will be the output if a = 5, b = 10, and c = 3?

            if(a > b && a > c)
                printf("a is Largest number");
            else if(b > a && b > c)
                printf("b is Largest number");
            else
                printf("c is Largest number");
                

21. What is the meaning of "nested if" statements?

22. How many levels of nested if statements can you have?

23. In a nested if structure, what happens if the outer if condition is false?

24. What is the syntax of an else if block in C?

25. What is the output of the following code if x = 7 and y = 5?

            if(x > 10)
            {
                if(y < 5)
                    printf("Nested if true");
                else
                    printf("Outer if true, inner if false");
            }
            else
            {
                printf("Outer if false");
            }
                

25. What is the function of the break keyword in C programming?

26. In which programming constructs can the break keyword be used?

27. What happens when a break statement is executed within a loop or switch block?

28. What does the continue keyword do in a loop?

29. What will happen if the continue statement is executed inside a loop?

30. What is the syntax of the continue statement?

31. Which of the following keywords are used in a switch statement in C programming?

32. Which of the following data types can be used in a switch expression?

33. What is the purpose of the break statement in a switch block?

34. If the switch expression does not match any case value, what will happen if a default statement is present?

35. What must follow each case value in a switch statement?

36. In a switch statement, are case values required to be in a specific order?

37. What is a nested switch statement?

38. In the nested switch example, what happens if the inner switch statement does not have a matching case value?

39. What is the output when no break is provided in a switch case?

40. What will happen if the break keyword is not used after a case in a switch statement?